<template>
  <div id="app">
    <the-header  v-if="isRouterAlive"/>
    <router-view class="music-content"/>
    <scroll-top/>
    <the-footer/>
  </div>
</template>

<script>
  import TheHeader from './components/TheHeader';
  import ScrollTop from './components/ScrollTop';
  import TheFooter from './components/TheFooter';

  export default {
    name: 'App',
    components: {
      TheHeader,
      ScrollTop,
      TheFooter,
    },
    provide() {    //父组件中通过provide来提供变量，在子组件中通过inject来注入变量。
      return {
        reload: this.reload
      }
    },
    data() {
      return {
        isRouterAlive: true                    //控制视图是否显示的变量
      }
    },
    methods: {
      reload() {
        this.isRouterAlive = false;            //先关闭，
        this.$nextTick(function () {
          this.isRouterAlive = true;         //再打开
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  @import './assets/css/app.scss';
</style>
